/**
* @program: src
*
* @description:orm映射处理,这里是对应rpc调用的方法
*
* @author: Mr.chen
*
* @create: 2020-12-16 14:15
**/
package orm

import (
	"ydd-im/service/api/define"
	"ydd-im/service/api/services/wsservice/account"
	"ydd-im/util/response"
)
/**
 *登录
 * @access  public
 * @param   string     username  账号
 * @param   string     passwd  密码
 * @param   string     client  客户端
 * @param   string     appkey  appkey
 * @return  map[string]interface{} data 用户信息
 * @return  error err
 */
func Login(username,passwd,client,appkey string) (res define.ExecResult) {
	res.Suc = true
	res.Msg = "ok"
	res.Code = response.SuccessCode
	data,err := account.Login(username,passwd,client,appkey)
	if err != nil {
		res.Suc = false
		res.Msg = err.Error()
		res.Code = response.ErrorCode
		return
	}
	res.Data = data
	return res
}
/**
 *登录
 * @access  public
 * @param   string     username  账号
 * @param   string     passwd  密码
 * @param   string     client  客户端
 * @param   string     appkey  appkey
 * @return  map[string]interface{} data 用户信息
 * @return  error err
 */
func Register(username,passwd,userkey,appkey string) (res define.ExecResult) {
	res.Suc = true
	res.Msg = "ok"
	res.Code = response.SuccessCode
	err := account.Register(username,passwd,userkey,appkey)
	if err != nil {
		res.Suc = false
		res.Msg = err.Error()
		res.Code = response.ErrorCode
		return
	}
	return res
}
